package de.deliancourt.jarvis.implementations;

import java.lang.Math;

import javax.vecmath.Point3d;



public class UISphere {
	
	static private double Radius = 15;
	
	
	
	static public void getSphereRadius (double r){
		Radius = r;
	}
	
	static public double getVertRadius ( double x, double y, double z) {
		return (float) Math.sqrt(Math.pow(x, 2)+ Math.pow(y, 2)+ Math.pow(z, 2));
	}

	static public double getAzimuth( double y, double x) {
		return (float) Math.toDegrees(Math.atan2(x, y));
	}

	static public double getPolarangle(double x, double y, double z) {
		return (float) Math.toDegrees(Math.acos(z/(getVertRadius(x,y,z)+Radius)));
	}


	static public double getRadius() {
		return Radius;
	}
	static public Point3d PointOnSphere (double x, double y, double z){
		Point3d tmp = new Point3d();
		double oldR = getVertRadius (x,y,z);
		tmp.x = (x/oldR)*Radius;
		tmp.y = (y/oldR)*Radius;
		tmp.z = (z/oldR)*Radius;
		return tmp;
	}
	
	
}
